import axios from 'axios'
import { CHANGE_BANNERS, CHANGE_RECOMMENDS } from './contants'

export const changeBannersAction = (banners) => ({
  type: CHANGE_BANNERS,
  banners: banners
})

export const changeRecommendsAction = (recommends) => ({
  type: CHANGE_RECOMMENDS,
  recommends: recommends
})

export const fetchHomeMultidataAction = () => {

  return (dispatch, getState) => {
    axios.get("http://123.207.32.32:8000/home/multidata").then(res => {
      const banners = res.data.data.banner.list;
      const recommends = res.data.data.recommend.list;
      dispatch(changeBannersAction(banners));
      dispatch(changeRecommendsAction(recommends));
    })
    
  }
}